package  
{
	import flash.display.Graphics;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.GradientType;
	import flash.geom.Matrix;
	
	/**
	 * 水晶球效果
	 * @author Fox
	 */
	public class CrystalBall extends Sprite 
	{
		//private var _light:Graphics;
		private var _r:Number;
		
		
		/**
		 * 构造函数
		 * @param        Radius
		 */
		public function CrystalBall(Radius:Number= 50) 
		{
			_r = Radius;
			init();
		}
		
		/**
		 * 初始化
		 */
		private function init():void
		{
			var _alp:Array = [1, 1];
			var _col:Array = [0xC2FE12,0x0F7B41];
			var _rat:Array = [0,255];
			var _matr:Matrix = new Matrix();
			var _scolR:Number = int(_r*2);
			_matr.createGradientBox(_scolR, _scolR,0, -_r, 0);
			this.graphics.beginGradientFill(GradientType.RADIAL, _col, _alp, _rat, _matr);
			this.graphics.drawCircle(0, 0, _r);
			this.graphics.endFill();
			
			var _light:Shape= new Shape();
			_col = [0xFFFFFF, 0xFFFFFF];
			_alp = [0.8, 0];
			_rat = [0, 180];                        
			_matr.createGradientBox(_r*0.1, _r,Math.PI*0.5, 0, -_r);
			_light.graphics.beginGradientFill(GradientType.LINEAR, _col, _alp, _rat,_matr);
			_light.graphics.drawCircle(0, -_r * 0.42, _r * 0.8);
			_light.graphics.endFill();
			_light.scaleY = 0.75;
			this.addChild(_light);
		}
		
	}
	
}